package com.medicine.hbp.ui;

import org.kymjs.kjframe.http.HttpParams;
import org.kymjs.kjframe.ui.BindView;

import android.text.TextUtils;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;

import com.medicine.hbp.base.BaseActivity;
import com.medicine.hbp.http.AppHttpCallBack;
import com.medicine.hbp.http.AppHttps;
import com.medicine.hbp.http.HttpInterface;
import com.medicine.hbp.uitl.ToastUtil;
import com.medicine.hbp.R;
/**
 * 意见反馈
 */
public class FeedBackActivity extends BaseActivity{
	@BindView(id=R.id.edit_feedback)public EditText edit_feedback;

	@Override
	public void setRootView() {
		super.setRootView();
		setContentView(R.layout.activity_feedback);
	}
	@Override
	public void initWidget() {
		super.initWidget();
		initTop();
	}
	@Override
	public void widgetClick(View v) {
		super.widgetClick(v);
	}
	private void initTop() {
		TopView topview = (TopView) findViewById(R.id.topview);
		topview.setTitle("建议反馈");
		topview.setLeftVisibility(View.GONE);
		topview.setLeftVisibilityExit(View.VISIBLE);
		topview.setRightVisibility(View.GONE);
		topview.setRightTxtVisibility(View.VISIBLE);
		topview.setRightTitleColor(getResources().getColor(R.color.black));
		topview.setRightTitle("提交");
		topview.setLeftOnClickExit(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				finish();
			}
		});
		topview.setTextRightOnClick(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				String content=edit_feedback.getText().toString();
				if(TextUtils.isEmpty(content)){
					ToastUtil.showShort(aty, "请填写您的反馈内容");
					return;
				}
				httpFeedBack(content);
			}
		});
	}
	/**
	 * 意见反馈提交接口
	 */
	private void httpFeedBack(String content) {
		HttpParams params = new HttpParams();
		params.put("msg", content);
		AppHttps.HttpPost(this, HttpInterface.ADD_OPINION, params,
				new AppHttpCallBack<Object>(Object.class,aty) {

					@Override
					public void onSuccess(Object result) {
						ToastUtil.showShort(aty, "提交成功");
						finish();
					}
					@Override
					public void onFailures(int errorCode, String errorMsg) {
						ToastUtil.showShort(aty, errorMsg);
					}
				});
	}

}
